import Vue from 'vue'
import VueRouter from 'vue-router'
import OrderList from '../views/OrderList.vue'
import Step from '../views/step/Index.vue'
import Cms from '../views/cms/Index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'OrderList',
    component: OrderList,
    meta: {
      title: '订单列表'
    }
  },
  {
    path: '/licence-list',
    name: 'LicenceList',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "licence" */ '../views/LicenceList.vue'),
    meta: {
      title: '许可证列表'
    }
  },
  {
    path: '/step/:path?',
    component: Step,
    children: [
      {
        path: 'order',
        component: () => import(/* webpackChunkName: "licence" */ '../views/step/Order.vue'),
        meta: {
          active: 0,
          title: '编辑订单'
        }
      },
      {
        path: 'company',
        component: () => import(/* webpackChunkName: "licence" */ '../views/step/Company.vue'),
        meta: {
          active: 1,
          title: '编辑订单'
        }
      },
      {
        path: 'goods',
        component: () => import(/* webpackChunkName: "licence" */ '../views/step/Goods.vue'),
        meta: {
          active: 2,
          title: '编辑订单'
        }
      },
      {
        path: 'file',
        component: () => import(/* webpackChunkName: "licence" */ '../views/step/Company.vue'),
        meta: {
          active: 3,
          title: '编辑订单'
        }
      },
    ],
  },
  {
    path: '/goods-list',
    name: 'GoodsList',
    component: () => import(/* webpackChunkName: "goods" */ '../views/GoodsList.vue'),
    meta: {
      title: '新鲜货品 / 货品列表'
    }
  },
  {
    path: '/order-file',
    name: 'OrderFile',
    component: () => import(/* webpackChunkName: "file" */ '../views/OrderFile.vue'),
    meta: {
      title: '文件管理 / 订单文件管理'
    }
  },
  {
    path: '/cms-file',
    name: 'CmsFile',
    component: () => import(/* webpackChunkName: "file" */ '../views/CmsFile.vue'),
    meta: {
      title: '文件管理 / 客户文件管理'
    }
  },
  {
    path: '/cms/:path?',
    component: Cms,
    children: [
      {
        path: 'customer',
        component: () => import(/* webpackChunkName: "licence" */ '../views/cms/Customer.vue'),
        meta: {
          title: '客户管理 / 客户'
        }
      },
      {
        path: 'consignee',
        component: () => import(/* webpackChunkName: "licence" */ '../views/cms/EditTab.vue'),
        meta: {
          title: '客户管理 / 收货单位'
        }
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
